<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>修改店铺</title>
    <link rel="shortcut icon" href="favicon.ico">

    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" th:href="@{/resource/css/bootstrap.min.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/font-awesome.min.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/animate.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/style.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/plugins/toastr/toastr.min.css}" />
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改店铺</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentForm" method="post">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-8">
                                <input id="name" type="text" class="form-control" name="name" required="" aria-required="true" th:value="${mode.name}">
                                <input id="id" type="hidden" class="form-control" name="id" required="" aria-required="true" th:value="${mode.id}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">描述：</label>
                            <div class="col-sm-8">
                                <input id="title" type="text" class="form-control" name="title" required="" aria-required="true" th:value="${mode.title}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺链接：</label>
                            <div class="col-sm-8">
                                <input id="shopurl" type="text" class="form-control" name="shopurl" required="" aria-required="true" th:value="${mode.shopurl}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺logo：</label>
                            <div class="col-sm-8">
                                <input id="logo" type="text" class="form-control" name="logo" required="" aria-required="true"  th:value="${mode.logo}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺地址：</label>
                            <div class="col-sm-8">
                                <input id="address" type="text" class="form-control" name="address" required="" aria-required="true"  th:value="${mode.address}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺分类：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="type" id="type">
                                </select>
                                <input id="type_tv" type="hidden" class="form-control" name="type_tv" required="" aria-required="true" th:value="${mode.type}">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">店铺类型：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="vtype" id="vtype">
                                    <option value="0">蓝转</option>
                                    <option value="1">黄转</option>
                                    <option value="2">天猫</option>
                                </select>
                                <input id="vtype_tv" type="hidden" class="form-control" name="vtype_tv" required="" aria-required="true" th:value="${mode.vtype}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">皇冠数量：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="crown" id="crown">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                </select>
                                <input id="crown_tv" type="hidden" class="form-control" name="crown_tv" required="" aria-required="true" th:value="${mode.crown}">
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">结束时间：</label>
                            <div class="col-sm-8">
                                <input id="endtime" type="text" class="form-control" name="endtime" required="" aria-required="true"  th:value="${mode.endtime}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="flag" id="flag">
                                    <option value="0">正常</option>
                                    <option value="1">停用</option>
                                </select>
                                <input id="flag_tv" type="hidden" class="form-control" name="flag_tv" required="" aria-required="true" th:value="${mode.flag}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input id="orderno" type="text" class="form-control" name="orderno"  value="0" required="" aria-required="true" th:value="${mode.orderno}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">浏览次数：</label>
                            <div class="col-sm-8">
                                <input id="clicks" type="text" class="form-control" name="clicks" required=""  value="0" aria-required="true" th:value="${mode.clicks}">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" id="category_submit" type="button">修改提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>

    </div>

</div>



<script type="text/javascript" th:src="@{/script/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/bootstrap.min.js}"></script>
<script th:src="@{/script/js/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/script/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script th:src="@{/script/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/contabs.js}"></script>
<script type="text/javascript" th:src="@{/script/js/plugins/toastr/toastr.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/common/common.js}"></script>
<script type="text/javascript" th:src="@{/script/js/common/menu/menu.js}"></script>
<script type="text/javascript" th:src="@{/script/js/plugins/validate/messages_zh.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/plugins/validate/jquery.validate.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/demo/form-validate-demo.js}"></script>
<script>

    $(function () {
        $("#flag").val($("#flag_tv").val());
        $("#vtype").val($("#vtype_tv").val());
        $("#type").val($("#type_tv").val());
        $("#crown").val($("#crown_tv").val());
        init();
    });

    function init() {
        $.ajax({
            url: "/common/category/categoryList",
            type: "get",
            contentType: "application/json",
            dataType:"json",
            success: function (data) {
                var html = "";
                for(var i=0;i<data.length;i++){
                    html = html+"<option value="+data[i].cid+">"+data[i].name+"</option>";
                }
                $("#type").append(html);
            }
        });
    }
    $("#category_submit").click(function () {
        var id = $("#id").val();
        var name = $("#name").val();
        var logo = $("#logo").val();
        var title = $("#title").val();
        var shopurl = $("#shopurl").val();
        var vtype = $("#vtype").val();
        var address = $("#address").val();
        var type = $("#type").val();
        var crown = $("#crown").val();
        var flag = $("#flag").val();
        var orderno = $("#orderno").val();
        var endtime = $("#endtime").val();
        var clicks = $("#clicks").val();
        if(name==""||logo==""||title==""||shopurl==""||vtype==""||crown==""||address==""||type==null){
            toastr.error("请补全信息!");
            return;
        }
        var mydata = '{"id":"'  + id + '","name":"'  + name + '","logo":"'+logo+'","title":"'+title+'","shopurl":"'+shopurl+'","vtype":"'+vtype+'","address":"'+address+'","type":"'+type+'","crown":"'+crown+'","flag":"'+flag+'","orderno":"'+orderno+'"' +
            ',"endtime":"'+endtime+'","clicks":"'+clicks+'"}';
        $.ajax({
            url: "/common/shop/updateShopModel",
            type: "post",
            data: mydata,
            contentType: "application/json",
            dataType:"json",
            success: function (data) {
                if(data["retType"] == "0") {
                    toastr.success("修改店铺成功!");
                    setTimeout( "window.location.href='/common/shop/doNewShopList'",1000);//延时3秒

                } else {
                    toastr.error(data["retMsg"]);
                }
            }
        });
    });
</script>

</body>

</html>